$OpenBSD: patch-src_amitk_common_c,v 1.3 2014/04/03 19:53:07 brad Exp $
--- src/amitk_common.c.orig	Thu Jan 23 16:47:18 2014
+++ src/amitk_common.c	Thu Mar 27 03:45:41 2014
@@ -275,25 +275,37 @@ gboolean amitk_is_xif_directory(const gchar * filename
 
     return TRUE;
   }
-  g_free(temp_str);
-
+  if (temp_str) {
+    g_free(temp_str);
+  }
+  
   /* figure out the name of the study file */
-  directory = opendir(xifname);
-      
+  if (xifname) {
+    directory = opendir(xifname);
+  }      
   /* currently, only looks at the first study_*.xml file... there should be only one anyway */
   if (directory != NULL) {
     while (((directory_entry = readdir(directory)) != NULL))
       if (g_pattern_match_simple("study_*.xml", directory_entry->d_name)) {
 	if (plegacy1 != NULL) *plegacy1 = FALSE;
 	if (pxml_filename != NULL) *pxml_filename = g_strdup(directory_entry->d_name);
-	closedir(directory);
-	
+	if (directory) {
+	  closedir(directory);
+	}
+	if (xifname) {
+	  g_free(xifname);
+	}
 	return TRUE;
       }
   }
     
-  closedir(directory);
-
+  if (directory) {  
+    closedir(directory);
+  }
+  if (xifname) {
+    g_free(xifname);
+  }
+  
   return FALSE;
 
 }
